//
//  HMVisitorController.swift
//  Weibo
//
//  Created by 李学林 on 15/12/6.
//  Copyright © 2015年 tete. All rights reserved.
//

import UIKit

class HMVisitorController: UITableViewController {

    var userLogin = HMWBUserInfoViewModel.sharedAccount.accessToken != nil;
    
    var visitorView: HMVisitorView?
    
    override func loadView() {
        
        userLogin ? super.loadView() : loadVisitorView()
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }
    
    private func loadVisitorView(){
    
       visitorView = HMVisitorView()
        
        visitorView?.registButton.addTarget(self, action: "login", forControlEvents: .TouchUpInside)
        visitorView?.loginButton.addTarget(self, action: "login", forControlEvents: .TouchUpInside)
        
       view = visitorView
        
        
        // 
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "login")
        navigationItem.rightBarButtonItem = UIBarButtonItem( title: "登录", target: self, action: "login")
        
    }
    
    
    func login(){
    
        printLog("控制器跳转")
        
        let nav = UINavigationController(rootViewController: HMOAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
    
    
    }
    

 

}
